﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace Abhiruchi_Phase1.BAL_DAL.ORG_DAL
{
    class SectionMasterDAL
    {
        public static string CS = App.ConnectionString;
        public static DataTable GetORGSectionMaster()
        {
            SqlConnection mycon = new SqlConnection(CS);
            SqlCommand mycom = new SqlCommand();
            mycom.Connection = mycon;
            mycom.CommandText = "SP_ORG_Get_Set_SectionMaster";
            mycom.CommandType = CommandType.StoredProcedure;
            mycom.Parameters.AddWithValue("@PType", 1);
            SqlDataAdapter myadp = new SqlDataAdapter(mycom);
            DataTable mydt = new DataTable();
            myadp.Fill(mydt);
            return mydt;
            
        }
        public static void GetSectionMasterInsert(string SectionName, string Description, int Location, string SectionInCharge, int IsActive)
        {
            SqlConnection mycon = new SqlConnection(CS);
            SqlCommand mycom = new SqlCommand();
            mycom.Connection = mycon;
            mycom.CommandText = "SP_ORG_Get_Set_SectionMaster";
            mycom.CommandType = CommandType.StoredProcedure;        
            mycom.Parameters.AddWithValue("@SectionName", SectionName);
            mycom.Parameters.AddWithValue("@Description", Description);
            mycom.Parameters.AddWithValue("@Location", Location);
            mycom.Parameters.AddWithValue("@SectionInCharge", SectionInCharge);
            mycom.Parameters.AddWithValue("@IsActive", IsActive);
            mycom.Parameters.AddWithValue("@PType", 2);
            using (mycon)
            {
                mycon.Open();
                mycom.ExecuteNonQuery();
            }
        }
        public static void GetSectionMasterUpdate(int SectionId,string SectionName, string Description, int Location, string SectionInCharge, int IsActive)
        {
            SqlConnection mycon = new SqlConnection(CS);
            SqlCommand mycom = new SqlCommand();
            mycom.Connection = mycon;
            mycom.CommandText = "SP_ORG_Get_Set_SectionMaster";
            mycom.CommandType = CommandType.StoredProcedure;
            mycom.Parameters.AddWithValue("@SectionId", SectionId);
            mycom.Parameters.AddWithValue("@SectionName", SectionName);
            mycom.Parameters.AddWithValue("@Description", Description);
            mycom.Parameters.AddWithValue("@Location", Location);
            mycom.Parameters.AddWithValue("@SectionInCharge", SectionInCharge);
            mycom.Parameters.AddWithValue("@IsActive", IsActive);
            mycom.Parameters.AddWithValue("@PType", 3);
            using (mycon)
            {
                mycon.Open();
                mycom.ExecuteNonQuery();
            }
        }

        public static DataTable GetORGSectionInchargeName()
        {
            SqlConnection mycon = new SqlConnection(CS);
            SqlCommand mycom = new SqlCommand();
            mycom.Connection = mycon;
            mycom.CommandText = "SP_ORG_Get_Set_SectionMaster";
            mycom.CommandType = CommandType.StoredProcedure;
            mycom.Parameters.AddWithValue("@PType", 5);
            SqlDataAdapter myadp = new SqlDataAdapter(mycom);
            DataTable mydt = new DataTable();
            myadp.Fill(mydt);
            return mydt;
        }
        public static DataTable GetORGSectionUpdateLocName()
        {
            SqlConnection mycon = new SqlConnection(CS);
            SqlCommand mycom = new SqlCommand();
            mycom.Connection = mycon;
            mycom.CommandText = "SP_ORG_Get_Set_SectionMaster";
            mycom.CommandType = CommandType.StoredProcedure;
            mycom.Parameters.AddWithValue("@PType", 6);
            SqlDataAdapter myadp = new SqlDataAdapter(mycom);
            DataTable mydt = new DataTable();
            myadp.Fill(mydt);
            return mydt;
        }
              

        public static DataTable GetORGSectionSecNameCompare(int SectionId, string SectionName)
        {
            SqlConnection mycon = new SqlConnection(CS);
            SqlCommand mycom = new SqlCommand();
            mycom.Connection = mycon;
            mycom.CommandText = "SP_ORG_Get_Set_SectionMaster";
            mycom.CommandType = CommandType.StoredProcedure;
            mycom.Parameters.AddWithValue("@SectionId", SectionId);
            mycom.Parameters.AddWithValue("@SectionName", SectionName);
            mycom.Parameters.AddWithValue("@PType", 7);
            SqlDataAdapter myadp = new SqlDataAdapter(mycom);
            DataTable mydt = new DataTable();
            myadp.Fill(mydt);
            return mydt;
        }

        public static DataTable GetORGSectionIdentity()
        {
            SqlConnection mycon = new SqlConnection(CS);
            SqlCommand mycom = new SqlCommand();
            mycom.Connection = mycon;
            mycom.CommandText = "SP_ORG_Get_Set_SectionMaster";
            mycom.CommandType = CommandType.StoredProcedure;
            mycom.Parameters.AddWithValue("@PType", 8);
            SqlDataAdapter myadp = new SqlDataAdapter(mycom);
            DataTable mydt = new DataTable();
            myadp.Fill(mydt);
            return mydt;
        }
        public static DataTable GetORGLoadLocNameSecInChrge()
        {
            SqlConnection mycon = new SqlConnection(CS);
            SqlCommand mycom = new SqlCommand();
            mycom.Connection = mycon;
            mycom.CommandText = "SP_ORG_Get_Set_SectionMaster";
            mycom.CommandType = CommandType.StoredProcedure;
            mycom.Parameters.AddWithValue("@PType", 9);
            SqlDataAdapter myadp = new SqlDataAdapter(mycom);
            DataTable mydt = new DataTable();
            myadp.Fill(mydt);
            return mydt;
        }
    }
}
